import org.apache.ibatis.annotations.*;

import java.util.List;

public interface RoleMapper<mybatis, locations, mapper, classpath> {


    // 查询所有角色
    @Select("SELECT * FROM role")
    List<Role> findAll();

    // 根据 ID 查询角色
    @Select("SELECT * FROM role WHERE id = #{id}")
    Role findById(@Param("id") Long id);

    // 插入角色
    @Insert("INSERT INTO role(role_name) VALUES(#{roleName})")
    @Options(useGeneratedKeys = true, keyProperty = "id") // 自动生成主键并设置到实体类中
    int insert(Role role);

    // 更新角色
    @Update("UPDATE role SET role_name = #{roleName} WHERE id = #{id}")
    int update(Role role);

    // 删除角色
    @Delete("DELETE FROM role WHERE id = #{id}")
    int deleteById(@Param("id") Long id);
}
